Cleaning scripts:

Load data:

Visualize probability ratings

exp_trials = rbind(exp_trials1, exp_trials2, exp_trials3, exp_trials4, exp_trials5, exp_trials6)

exp_trials$prob = factor(exp_trials$prob)

ggplot(data = exp_trials) +
  geom_boxplot(mapping = aes(x = prob, y = prob_rating, fill = prob))

Visualize mood ratings

mood1 = format_mood(read.csv("../../06_exp_away/data/06_exp_away_cond1-mood_ratings.csv"))
mood1$Answer.condition = "optimist"
mood2 = format_mood(read.csv("../../04_exp_away/data/04_exp_away_cond2-mood_ratings.csv"))
mood2$Answer.condition = "confident"
mood3 = format_mood(read.csv("../../04_exp_away/data/04_exp_away_cond3-mood_ratings.csv"))
mood3$Answer.condition = "pessimist"
mood4 = format_mood(read.csv("../../04_exp_away/data/04_exp_away_cond4-mood_ratings.csv"))
mood4$Answer.condition = "cautious"
mood5 = format_mood(read.csv("../data/07_exp_away_incongruent_cond5-mood_ratings.csv"))
mood5$Answer.condition = "optimist_incongruent"
mood6 = format_mood(read.csv("../data/07_exp_away_incongruent_cond6-mood_ratings.csv"))
mood6$Answer.condition = "pessimist_incongruent"



mood2$workerid = mood2$workerid + max(mood1$workerid) + 1
mood3$workerid = mood3$workerid + max(mood2$workerid) + 1
mood4$workerid = mood4$workerid + max(mood3$workerid) + 1
mood5$workerid = mood5$workerid + max(mood4$workerid) + 1
mood6$workerid = mood6$workerid + max(mood5$workerid) + 1

mood_all = rbind(mood1, mood2, mood3, mood4, mood5, mood6)

mood1_all = mood_all %>%
  filter(type == "mood1") %>%
  mutate(mood1 = mood_rating) %>%
  mutate(mood_rating = NULL) %>%
  mutate(type = NULL)

mood2_all = mood_all %>%
  filter(type == "mood2") %>%
  mutate(mood2 = mood_rating) %>%
  mutate(mood_rating = NULL) %>%
  mutate(type = NULL)


mood_all = merge(mood1_all, mood2_all)

mood_by_participant = mood_all

mood_by_participant$diff = mood_all$mood2 - mood_all$mood1

moodp1 = ggplot(data = mood_by_participant) +
  geom_bar(mapping = aes(x = workerid, y = diff, fill = Answer.condition), stat = "identity")

moodp1

Exclude random responses

exclude_random = function(d) {
  d_overall_means = d %>%
  group_by(modal, workerid) %>% 
  summarise(rating_m_overall = mean(rating))

  d_indiv_means =  d %>%
    group_by(modal,percent_window, workerid) %>% 
    summarise(rating_m = mean(rating))
  
  d_indiv_merged = merge(d_indiv_means, d_overall_means, by=c("workerid", "modal"))
  
  cors = d_indiv_merged %>%
    group_by(workerid) %>%
    summarise(corr = cor(rating_m, rating_m_overall))
  
  exclude = cors %>%
    filter(corr > 0.75) %>%
    .$workerid
  
  print(paste("Excluded", length(exclude), "participants based on random responses."))
  
  d = d %>% filter(!(workerid %in% exclude))
}

d1 = exclude_random(d1)
## [1] "Excluded 18 participants based on random responses."
d2 = exclude_random(d2)
## [1] "Excluded 11 participants based on random responses."
d3 = exclude_random(d3)
## [1] "Excluded 9 participants based on random responses."
d4 = exclude_random(d4)
## [1] "Excluded 14 participants based on random responses."
d5 = exclude_random(d5)
## [1] "Excluded 15 participants based on random responses."
d6 = exclude_random(d6)
## [1] "Excluded 12 participants based on random responses."

Aggregated results

## Individual plots

#plot(ps2$by_participant)
#plot(ps3$by_participant)
#plot(ps4$by_participant)

AUC Computation

## 
##  Two Sample t-test
## 
## data:  aucs.confident$auc_diff and aucs.cautious$auc_diff
## t = -5.1755, df = 133, p-value = 8.188e-07
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -21.21955  -9.48492
## sample estimates:
## mean of x mean of y 
##  1.615644 16.967878
## 
## Cohen's d
## 
## d estimate: -0.8910875 (large)
## 95 percent confidence interval:
##      lower      upper 
## -1.2481363 -0.5340387
## 
##  Two Sample t-test
## 
## data:  aucs.optimist_incongruent$auc_diff and aucs.pessimist_incongruent$auc_diff
## t = 5.8965, df = 131, p-value = 2.978e-08
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  11.98072 24.07832
## sample estimates:
## mean of x mean of y 
## 16.954712 -1.074805
## 
## Cohen's d
## 
## d estimate: 1.022841 (large)
## 95 percent confidence interval:
##     lower     upper 
## 0.6579456 1.3877371
## [1] "p-value according to permutation test: 0.265"